#region Using Statements
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
#endregion

namespace MyFirstXNAGame.Source.Characters
{
    class Swirl : Sprite
    {
        public Swirl(String texturePath, GraphicsDeviceManager graphics)
        {
            this.texturePath = texturePath;
            this.spriteSpeed = new Vector2(random.Next(50, 250), random.Next(50, 250));
            this.rotation = 0.0f;            
            this.layer = 1.0f;
            this.rectangle = new Rectangle();
            this.color = Color.White;
            this.spriteEffects = SpriteEffects.None;
            this.scale = 1.0f;
            this.spritePosition = new Vector2(random.Next(720), random.Next(480));
            rotationSpeed = 0.1f;
        }
        public override void updatePosition(GameTime gameTime, GraphicsDeviceManager graphics)
        {
            this.origin = new Vector2(this.spriteTexture.Width / 2, this.spriteTexture.Height / 2);
            spritePosition += spriteSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            rotation += rotationSpeed;

            int MaxX = graphics.GraphicsDevice.Viewport.Width - spriteTexture.Width;
            int MinX = 0;
            int MaxY = graphics.GraphicsDevice.Viewport.Height - spriteTexture.Height;
            int MinY = 0;

            // Check for bounce.
            if (spritePosition.X - origin.X > MaxX)
            {
                spriteSpeed.X *= -1;
                spritePosition.X = MaxX + origin.X;
            }

            else if (spritePosition.X - origin.X< MinX)
            {
                spriteSpeed.X *= -1;
                spritePosition.X = MinX + origin.X;
            }

            if (spritePosition.Y - origin.Y> MaxY)
            {
                spriteSpeed.Y *= -1;
                spritePosition.Y = MaxY+origin.Y;
            }

            else if (spritePosition.Y - origin.Y< MinY)
            {
                spriteSpeed.Y *= -1;
                spritePosition.Y = MinY+origin.Y;
            }
        }
    }
}
